package prova.util;

import java.sql.Connection;
import java.sql.DriverManager;

import prova.daos.DaoProva;
import prova.model.Prova;

public class Conexao {

	public static Connection getConnection(){
		try{
			Class.forName("com.mysql.jdbc.Driver");
			return DriverManager.getConnection(
					"jdbc:mysql://localhost/prova", "root", "");
		}catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
	
	public static void main(String[] args) {
		Connection c = getConnection();
		if(c == null){
			System.out.println("nok");
		}
		else{
			System.out.println("ok");
			Prova p = new Prova();
			p.setNome("WILLPOWER");
			p.setAcesso("ALL");
			p.setCurso("COMP");
			p.setPerfil("CAB");
			p.setSenha("1");
			p.setSexo("M");
			DaoProva dao = new DaoProva();
			dao.salvar(p);
		}
	}
	
}